import * as React from 'react';
import dayjs from 'dayjs';
import InputNumber from 'antd/lib/input-number';

import './index.less';

const {
    forwardRef, useRef, useState
} = React;

const MAX_YEAR = new Date().getFullYear() + 1;
const MIN_YEAR = new Date().getFullYear() - 1;

interface DateInputProps {
    time: dayjs.Dayjs,
    controller: any
}




export const DateInput = forwardRef(function (props: DateInputProps, ref) {
    const {
        time,
        controller
    } = props;

    const {
        year, setYear,
        month, setMonth,
        date, setDate,
        hour, setHour,
        minute, setMinute
    } = controller;
    const wrapRef = useRef(null);


    return (
        <div ref={wrapRef}>
            <InputNumber className="ward-dateinput-year" max={MAX_YEAR} min={MIN_YEAR} onChange={setYear} value={year}></InputNumber>年
            <InputNumber className="ward-dateinput" max={12} min={1} onChange={setMonth} value={month}></InputNumber>月
            <InputNumber className="ward-dateinput" max={31} min={1} onChange={setDate} value={date}></InputNumber>日
            <InputNumber className="ward-dateinput" max={23} min={0} onChange={setHour} value={hour}></InputNumber>时
            <InputNumber className="ward-dateinput" max={59} min={0} onChange={setMinute} value={minute}></InputNumber>分
        </div>
    )
});
